package com.crhms.seabow.service;

import com.crhms.seabow.entity.Lesson;
import com.crhms.seabow.repository.LessonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LessonService {

    @Autowired
    private LessonRepository lessonRepository;

    public List<Lesson> getLessons() {

        List<Lesson> all = lessonRepository.selectList(null);

        return all;
    }

    public List<Lesson> getCategoryLessons() {

        List<Lesson> all = lessonRepository.selectList(null);

        return  all;
    }

    public void saveLesson(int lessonId, String name){

        Lesson lesson = new Lesson();
        lesson.setName(name);
        lesson.setId(lessonId);
        lesson.setBookId("2");
        lesson.setSrc("");
        lessonRepository.insert(lesson);
    }
}
